
/**
* @Title: ItemServiceImpl.java
* @Package com.leetone.service
* @Description: 【】
* @date 2018年3月10日 下午9:45:24
* @version V1.0
* @Company: 上海
* @author:[谭磊][leetone123@163.com]
*/

package com.leetone.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.leetone.mapper.ItemMapper;
import com.leetone.pojo.Item;
import com.leetone.pojo.ItemExample;
import com.leetone.vo.EUDataGridResult;

/**
* @ClassName: ItemServiceImpl
* @Description: 【】
* @date 2018年3月10日 下午9:45:24
* @Company: 上海
* @author:[谭磊][leetone123@163.com]
*/
@Service
public class ItemServiceImpl implements ItemService {
	@Autowired
	private ItemMapper itemMapper;
	@Override
	public Item getItemById(long id) {
		return itemMapper.selectByPrimaryKey(id);
		//根据查询条件查询
		/*ItemExample example = new ItemExample();
		Criteria criteria = example.createCriteria();
		criteria.andIdEqualTo(id);
		List<Item> list = itemMapper.selectByExample(example);
		if(list!=null && list.size()>0)
		{
			return list.get(0);
		}
		return null;*/
	}
	@Override
	public EUDataGridResult getItemList(int page,int rows) {
		//设置分页
		PageHelper.startPage(page, rows);
		//创建查询条件
		ItemExample example =new ItemExample();
		List<Item> list =itemMapper.selectByExample(example);
		//创建EasyUiDataGrid对象
		EUDataGridResult result = new EUDataGridResult();
		result.setRows(list);
		//查询总条数
		PageInfo<Item> info = new PageInfo<>(list);
		result.setTotal(info.getTotal());
		return result;
	}
	
	
}
